package com.example.demo.alarm.controller;

import com.example.demo.alarm.dao.AlarmTactics;
import com.example.demo.alarm.service.AlarmTacticsService;
import com.example.demo.system.utility.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 报警策略
 */
@RequestMapping("alarmTactics")
@RestController
public class AlarmTacticsController {

    @Autowired
    private AlarmTacticsService alarmTacticsService;


    //获取报警策略集合
    @RequestMapping("getList")
    public Result getList(@RequestParam(value = "pageNum") Integer pageNum,
                          @RequestParam(value = "pageSize") Integer pageSize,
                          @RequestParam(value = "name", required = false) String name,
                          @RequestParam(value = "healthOrComfort") String healthOrComfort) {
        return alarmTacticsService.getList(pageNum, pageSize, name, healthOrComfort);
    }

    //获取报警策略详情
    @RequestMapping("get")
    public Result get(Integer id) {
        return alarmTacticsService.get(id);
    }

    //新增报警策略（所关联的传感器需要是一个设备中的）
    @RequestMapping("add")
    public Result add(@RequestBody AlarmTactics alarmTactics) {
        return alarmTacticsService.add(alarmTactics);
    }

    //修改报警策略（所关联的传感器需要是一个设备中的）
    @RequestMapping("update")
    public Result update(@RequestBody AlarmTactics alarmTactics) {
        return alarmTacticsService.update(alarmTactics);
    }

    //删除报警策略
    @RequestMapping("delete")
    public Result delete (Integer id) {
        return alarmTacticsService.delete(id);
    }


    //删除关联传感器
    @RequestMapping("deleteSensor")
    public Result deleteSensor (Integer sensorId) {
        return alarmTacticsService.deleteSensor(sensorId);
    }


}
